package com.zhihuishu.micro.course.openapi.onlinescore.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zhihuishu.micro.course.model.ScoreAssessRule;
import com.zhihuishu.micro.course.openapi.onlinescore.ScoreAssessRuleOpenService;
import com.zhihuishu.micro.course.openapi.onlinescore.dto.ScoreAssessRuleOpenDto;
import com.zhihuishu.micro.course.service.ScoreAssessRuleService;
import com.zhihuishu.remote.RemoteResult;
import com.zhihuishu.toolkit.helper.BeanHelper;

/** 
 * @author yulijin 
 * @version 创建时间：2016年12月6日 下午2:35:06 
 * 类说明 
 */
@Service("scoreAssessRuleOpenServiceForOnlineScore")
public class ScoreAssessRuleOpenServiceImpl implements ScoreAssessRuleOpenService {
	@Resource
	private ScoreAssessRuleService scoreAssessRuleService;
	@Override
	public RemoteResult<ScoreAssessRuleOpenDto> findScoreAssessRuleByCourseId(Long courseId) {
		
		RemoteResult<ScoreAssessRuleOpenDto> result = new RemoteResult<ScoreAssessRuleOpenDto>();
		
		try {
			ScoreAssessRule scoreAssessRule = scoreAssessRuleService.findByCourseId(courseId);
			result.setResult(null == scoreAssessRule ? null : BeanHelper.transTo(scoreAssessRule,ScoreAssessRuleOpenDto.class));
			result.setSuccess(true);
		} catch (Exception e) {
			result.setResult(null);
			result.setSuccess(false);
			result.setExceptionStack(e);
		}
		
		return result;
	}

}
